package com.cssw.fyzb.core.dao.system;

import com.cssw.fyzb.core.model.dodb.SysFunc;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author yangyiqun
 * @create 2020-08-10 11:09
 */
@Repository
public class MenuDaoImpl implements MenuDao {

    @Override
    public List<SysFunc> queryFuncListByOperId(Long operId) {
        StringBuffer sql = new StringBuffer();

        sql.append("select distinct t1.* ")
                .append(" from sys_func t1, sys_role_func t2, sys_oper_role t3 where t3.oper_id = ? and t2.role_id = t3.role_id ")
                .append(" and t1.func_id = t2.func_id and t1.status = ?")
                .append(" and t1.func_type in ('1','2')");

        return SysFunc.dao.find(sql.toString(), operId, SysFunc.STATUS_START);
    }

    @Override
    public List<SysFunc> listAllFunc() {
        StringBuffer sql = new StringBuffer();

        sql.append("select t1.* ")
                .append(" from sys_func t1 ")
                .append(" where t1.status = ?")
                .append(" and t1.func_type in ('1','2')");

        return SysFunc.dao.find(sql.toString(), SysFunc.STATUS_START);
    }
}
